<template>
    <div class="dashboard-container">
        <Navbar />
        <div class="content-container">
            <!-- 路由区 -->
            <div class="sidebar">
                <div class="sidebar-header">
                    <h2>数据统计</h2>
                </div>
                <nav class="sidebar-nav">
                    <RouterLink v-for="item in sidebarItems" :key="item.name" :to="`/DataStatistics/${item.path}`"
                        class="sidebar-link" active-class="active">
                        <span class="link-icon">{{ item.icon }}</span>
                        <span class="link-text">{{ item.label }}</span>
                    </RouterLink>
                </nav>
            </div>
            <!-- 展示区 -->
            <main class="main-content">
                <div class="content-wrapper">
                    <RouterView />
                </div>
            </main>
        </div>
    </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { RouterLink, RouterView } from 'vue-router';
import Navbar from '../components/Navbar.vue';


// 侧边栏菜单项
const sidebarItems = ref([
    { name: 'OrderManagement', path: 'OrderManagement', label: '订单管理', icon: '📋' },
    { name: 'ScoringData', path: 'ScoringData', label: '评分数据', icon: '📊' },
]);

</script>

<style scoped>
.dashboard-container {
    padding: 20px;
    min-height: 100vh;
    background-color: #f5f7fa;
    overflow: hidden;
}

.content-container {
    display: flex;
    flex: 1;
    margin: 0;
    gap: 20px;
    height: calc(92vh - 40px);
}

.sidebar {
    width: 210px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    height: 100%;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #e6e9ed;
}

.sidebar-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #34495e;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 0;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: #7f8c8d;
    text-decoration: none;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.sidebar-link:hover {
    background-color: #f8f9fa;
    color: #34495e;
    padding-left: 25px;
}

.sidebar-link.active {
    background-color: #f0f9ff;
    color: #3498db;
    border-left-color: #3498db;
    font-weight: 600;
}

.link-icon {
    font-size: 18px;
    margin-right: 12px;
    width: 20px;
    text-align: center;
}

.link-text {
    font-size: 14px;
}

.main-content {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 transparent;
}

.main-content::-webkit-scrollbar {
    width: 6px;
}

.main-content::-webkit-scrollbar-track {
    background: transparent;
}

.main-content::-webkit-scrollbar-thumb {
    background-color: #c1c1c1;
    border-radius: 3px;
}

.content-wrapper {
    background-color: white;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    min-height: 100%;
    height: auto;
}

@media (max-width: 1024px) {
    .sidebar {
        width: 200px;
    }

    .sidebar-header h2 {
        font-size: 18px;
    }

    .link-text {
        font-size: 13px;
    }
}

@media (max-width: 768px) {
    .content-container {
        flex-direction: column;
        padding: 15px;
        gap: 15px;
        height: calc(100vh - 30px);
    }

    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        overflow-x: auto;
        padding: 10px;
        max-height: 120px;
    }

    .sidebar-header {
        display: none;
    }

    .sidebar-nav {
        display: flex;
        padding: 0;
        gap: 10px;
    }

    .sidebar-link {
        flex-direction: column;
        padding: 15px 10px;
        min-width: 80px;
        border-left: none;
        border-bottom: 3px solid transparent;
        text-align: center;
    }

    .sidebar-link.active {
        border-left-color: transparent;
        border-bottom-color: #3498db;
    }

    .link-icon {
        margin-right: 0;
        margin-bottom: 5px;
    }

    .content-wrapper {
        padding: 16px;
        min-height: 100%;
        height: auto;
    }
}
</style>
